package com.yzl.frelink.entities.chart;

import lombok.Data;

@Data
public class Parameter {
    String name;
    String type; // int8, double, boolean, string
    String initVal;
    int scope; // 0: local, 1: input, 2: output
    public static final int LOCAL = 0;
    public static final int INPUT = 1;
    public static final int OUTPUT = 2;
    String master; // 该参数所属的chart名称

    public Parameter(String name, int scope) {
        this.name = name;
        this.scope = scope;
        this.type = "boolean"; // 默认设置为boolean类型
        this.initVal = "false";
    }

    public void initParameter(String type) {
        this.type = type;
        switch (type) {
            case "int8":
                this.initVal = "0";
                break;
            case "double":
                this.initVal = "0.0";
                break;
            case "bool":
                this.initVal = "false";
                break;
            case "string":
                this.initVal = "\"\"";
                break;
            default:
                this.initVal = "null";
                break;
        }
    }

    public String getScopeStr() {
        switch (this.scope) {
            case INPUT:
                return "Input";
            case OUTPUT:
                return "Output";
            case LOCAL:
                return "Local";
            default:
                return "Local";
        }
    }
}
